package com.clouddot.baipai.infrastructure.environment;

import android.content.Context;

import com.clouddot.baipai.model.beam.TargetUrl;
import com.clouddot.baipai.model.netConnect;
import com.clouddot.baipai.presenter.appPresenter;
import com.clouddot.baipai.ui.util.Ftp.FTPUtil;
import com.clouddot.baipai.ui.util.Log.LogUtil;
import com.clouddot.baipai.ui.util.dbHelper.SharedPreferencesHelper;

/**
 * Created by wxy on 2018/4/9.
 */

public class Env {

    public static appContext getAppContext(){

        return Environment.getInstance() != null ?Environment.getInstance().appContext : null;
    }
    public static TargetUrl getTargetUrl(){
        return Environment.getInstance().targetUrl;
    }
    public static appPresenter getAppPresenter(){
        return Environment.getInstance().appPresenter;
    }
    public static netConnect getNetConnect(){
        return Environment.getInstance().netConnect;
    }
    public static FTPUtil getFTPUtil(){
        return Environment.getInstance().ftpUtil;
    }
    public static SharedPreferencesHelper getHelper(){return  Environment.getInstance().helper;}
    public static void error(String msg){
        LogUtil.e(msg);
        String path = Environment.getInstance().fileUtil.createIfNotExist("mnt/sdcard/BanPai/Log/error", Environment.getInstance().fileUtil.createFileName());
        Environment.getInstance().fileUtil.writeString(path,msg);
    }

    public static void info(String msg){
        LogUtil.i(msg);
        String path = Environment.getInstance().fileUtil.createIfNotExist("mnt/sdcard/BanPai/Log/info", Environment.getInstance().fileUtil.createFileName());
        Environment.getInstance().fileUtil.writeString(path,msg);

    }

    public static void debug(String msg){
        LogUtil.d(msg);
        String path = Environment.getInstance().fileUtil.createIfNotExist("mnt/sdcard/BanPai/Log/debug", Environment.getInstance().fileUtil.createFileName());
        Environment.getInstance().fileUtil.writeString(path,msg);
    }

    public static void warn(String msg){
        LogUtil.w(msg);
        String path = Environment.getInstance().fileUtil.createIfNotExist("mnt/sdcard/BanPai/Log/warn", Environment.getInstance().fileUtil.createFileName());
        Environment.getInstance().fileUtil.writeString(path,msg);
    }

    public static void sysInfo(String msg){
        LogUtil.d(msg);
        String path = Environment.getInstance().fileUtil.createIfNotExist("mnt/sdcard/BanPai/Log/sysInfo", Environment.getInstance().fileUtil.createFileName());
        Environment.getInstance().fileUtil.writeString(path,msg);
    }

    public static Context getContent(){
        return Environment.getInstance().context;
    }
}
